package com.sky.controller.user;

import com.sky.constant.RedisConstant;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: WangHongKun
 * @Date: 2022/9/22 16:58
 * @Email: 2028911483@qq.com
 * @Phone: 18683977706
 */

@RestController("UserShopController")
@Slf4j
@Api(tags = "店铺操作相关接口")
@RequestMapping("/user/shop")
public class ShopController {


    @Autowired
    private RedisTemplate redisTemplate;


    /**
     * 获取营业状态
     * @return
     */
    @GetMapping("/status")
    @ApiOperation("获取营业状态接口")
    public Result getStatus(){
        ValueOperations valueOperations = redisTemplate.opsForValue();
        log.info("当前店铺的营业状态为：{}", (Integer) valueOperations.get(RedisConstant.SHOP_STATUS) == 1? "营业中":"打烊中" );
        return Result.success( valueOperations.get(RedisConstant.SHOP_STATUS));
    }

}
